<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>${member.realname}的积分列表</title>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">
    <%@include file="../include/commonFile.jsp" %>
</head>
<body>
<!--头部-->
<%@include file="../include/header.jsp" %>
<div class="index-outside">
    <%@include file="../include/sidebar.jsp" %>
    <!--内容-->
    <section>
        <div class="section-main">
            <form class="layui-form" action="${ctx}/member/integral/userIntegral/list.do" id="myForm" method="post">
                <input type="hidden" name="pageNo" id="pageNo"/>
                <input type="hidden" name="pmId" value="${cUserIntegral.pmId}"/>
                <input type="hidden" name="partnerId" value="${partnerId}"/>

                <div class="f-search-bar">
                    <div class="search-container">
                        <ul class="search-form-content">
                            <li class="form-item-inline"><label class="search-form-lable">积分类型</label>
                                <div class="layui-input-inline">
                                    <select name="integralTypeId">
                                        <option value="">全部</option>
                                        <c:forEach var="type" items="${cIntegralTypes}">
                                            <option value="${type.id}" ${cUserIntegral.integralTypeId == type.id ? 'selected="selected"' : ''}>${type.name}</option>
                                        </c:forEach>
                                    </select>
                                </div>
                            </li>
                            <li class="form-item-inline"><label
                                    class="search-form-lable">积分项名</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="integralItemName" autocomplete="off" class="layui-input"
                                           value="${cUserIntegral.integralItemName}" placeholder="请输入积分项名">
                                </div>
                            </li>
                            <li class="form-item-inline">
                                <div class="sub-btns">
                                    <a class="layui-btn layui-btn-danger"
                                       href="javascript:submitFunction('#myForm')">查询</a>
                                    <a class="layui-btn layui-btn-normal"
                                       href="javascript:resetFunction('#myForm')">重置</a>
                                </div>
                            </li>
                        </ul>
                        <ul class="search-form-content">
                            <li class="form-item"><label class="search-form-lable">更新时间</label>
                                <div class="check-btn-inner" id="timeType">
                                    <a id="all" href="javascript:void(0);"
                                       onclick="setTimeType($(this),0,'#myForm')" ${empty input.timeType || input.timeType == 0 ? 'class="active"' : ''}>全部</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),1,'#myForm')" ${input.timeType == 1 ? 'class="active"' : ''}>今天</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),2,'#myForm')" ${input.timeType == 2 ? 'class="active"' : ''}>本周内</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),3,'#myForm')" ${input.timeType == 3 ? 'class="active"' : ''}>本月内</a>
                                    <input type="hidden" name="timeType" value="${input.timeType}"/>
                                </div>
                                <div class="layui-inline">
                                    <div class="layui-input-inline">
                                        <input class="layui-input" type="text" name="createStart"
                                               value="${input.createStart}" placeholder="开始日">
                                    </div>
                                    -
                                    <div class="layui-input-inline">
                                        <input class="layui-input" type="text" name="createEnd"
                                               value="${input.createEnd}" placeholder="截止日">
                                    </div>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </form>
            <div class="list-content">
                <div class="cl">
                    <table class="layui-table">
                        <colgroup>
                            <col width="20%">
                            <col width="35%">
                            <col width="150">
                            <col width="160">
                            <c:if test="${!isChild || isXzgsAdmin}">
                                <col width="150">
                            </c:if>
                        </colgroup>
                        <thead>
                        <tr>
                            <th>类型</th>
                            <th>积分项名称</th>
                            <th>分数</th>
                            <th>更新时间</th>
                            <c:if test="${!isChild || isXzgsAdmin}">
                                <th>操作</th>
                            </c:if>
                        </tr>
                        </thead>
                        <tbody>
                        <c:forEach var="cUserIntegral" items="${cUserIntegralOutputs}">
                            <tr class="detail-content1">
                                <td>
                                    <div>${cUserIntegral.cTypeName}</div>
                                </td>
                                <td>
                                    <div>${cUserIntegral.cItemName}</div>
                                </td>
                                <td>
                                    <div>${cUserIntegral.itemFraction}</div>
                                </td>
                                <td>
                                    <div><fmt:formatDate value="${cUserIntegral.updateDate}"
                                                         pattern="yyyy-MM-dd HH:mm"/></div>
                                </td>
                                <c:if test="${!isChild || isXzgsAdmin}">
                                    <td class="opts-btns tb-opts" style="width:350px">
                                        <div class="comm-opts">
                                            <c:if test="${cUserIntegral.category == 0}">
                                                <a class="green"
                                                   href="javascript:editIntegral('${cUserIntegral.memberId}','${cUserIntegral.id}','')">编辑</a>
                                            </c:if>
                                            <a class="red"
                                               href="javascript:txz.deleteObject('确定要删除吗？','${ctx}/member/integral/userIntegral/delete.do?id=${cUserIntegral.id}');">删除</a>
                                        </div>
                                    </td>
                                </c:if>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                    <c:if test="${page.totalCount == 0}">
                        <div class="f16 tc mt15">还没有数据</div>
                    </c:if>
                </div>
            </div>
            <div id="page_content" class="page-container"></div>
        </div><!--底部-->
        <%@include file="../include/footer.jsp" %>
    </section>
</div>

<script type="text/javascript" src="${ctx}/script/common/list.js"></script>
<script type="text/javascript" src="${ctx}/script/common/table_option.js"></script>
<script type="text/javascript">
    var form;
    $(function () {
        //加载分页
        loadPageNew({
            elem: 'page_content',
            totalCount: '${page.totalCount}',
            limit: '${page.limit}',
            page: '${page.page}'
        });
        layui.use(['laydate', 'form'], function () {
            form = layui.form;
            var laydate = layui.laydate;
            var start = {
                elem: 'input[name=createStart]'
            };
            var end = {
                elem: 'input[name=createEnd]'
            };
            laydate.render(start);
            laydate.render(end);

            // 积分类型
            form.on('select(types)', function (data) {
                var typeId = data.value
                $("#items").html("");
                $("#itemFractionVal").html("")
                loadIntegralItemssData(typeId, "");
            });
            // 积分类型
            form.on('select(items)', function (data) {
                $("#itemFractionVal").html("")
                var itemFractionVal = $(data.elem).find("option:selected").attr("fractionVal");
                $("#itemFractionVal").html(itemFractionVal);
            });
        })
    })

    function editIntegral(memberId, uiId,partnerId) {
        layer.open({
            type: 2,
            area: ['600px', '400px'],
            title: '${not empty uiId ? '编辑积分': '添加积分'}',
            maxmin: false,
            content: '${ctx}/member/integral/userIntegral/form.do?memberId=' + memberId + '&id=' + uiId+'&partnerId='+partnerId,
            btn: ['提交', '关闭'],
            yes: function (index, layero) {
                var body = layer.getChildFrame('body', index);
                var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                var inputForm = body.find('#inputForm');
                var top_iframe;
                top_iframe = '_parent';//获取当前active的tab的iframe

                inputForm.attr("target", top_iframe);//表单提交成功后，从服务器返回的url在当前tab中展示

                var loadIndex = layer.load(1, {
                    shade: [0.1, '#fff'] //0.1透明度的白色背景
                });

                if (iframeWin.contentWindow.submitForm()) {
                    layer.close(loadIndex);
                    setTimeout(function () {
                        top.layer.close(index);

                        location.reload();
                    }, 100);//延时0.1秒，对应360 7.1版本bug
                } else {
                    layer.close(loadIndex);
                    return false;
                }
            },
            cancel: function (index) {
            }
        });
    }

    txz.initHeader({
        nav: [{
            name: '',
            curr: true
        }],
        info: '<span class="f18"> <strong>${member.realname}</strong>  的积分项列表<span> <br/><span class="f14">共<b>${page.totalCount}</b>条记录，共获得积分：<font class="active-red f20">${fractionSum == null? 0.0:fractionSum}</font</span>',
        btns: [{
            name: '添加积分',
            icon: 'add',
            href: 'javascript:editIntegral(\'${member.id}\', \'\',\'${partnerId}\')'
        }, {
            name: '返回',
            icon: 'back',
            href: '${ctx}/member/membermgmt/list.do'
        }]
    });


</script>
</body>
</html>